<%@page import="util.Utilities"%>
<%@page import="dao.Course"%>
<%@page import="beans.Coursebean"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
    String grade = null;
 	List<Course> list = null;
 	Coursebean coursebean = new Coursebean();
 	if(session.getAttribute("grade") !=null){
 		grade = (String)session.getAttribute("grade") ;
 		list = coursebean.getCourseByGrade(grade);
 }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>章节知识预览</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	font: normal 16px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: left;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 1280px;
	height: 800px;
	background: #f8f8f8;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 30px;
	margin-botton: 30px;
	text-align: left;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
</head>
<body>
<div id="container">
	<c:choose>
		<c:when test="<%=list==null %>">
			<c:out value="参数有误，没有相应年级的信息"></c:out>
		</c:when>
		<c:otherwise>
			<%
			    for (Course course : list) {
			%>
			<div class="ele">
			<h3><%=course.getName()%></h3>
			<%
			    int counts = course.getChaptercounts();

						for (int i = 0; i < counts; i++) {
						    StringBuffer idString = new StringBuffer();
						    if (i < 9) {
							idString.append("0").append(i + 1);
						    } else {
							idString.append(i + 1);
						    }
			%>
			<a
				href="./common/chapter.jsp?chapterid=<%=course.getCourseid()
				    + idString.toString()%>">第<%=i + 1%>章</a>
				    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				    <%
				        if ((i+1)%5 == 0) {
				    				out.write("<br>");
				    			    }
				    			}
				    %>
				    </div>
				    <hr>
			<%
			    }
			%>
		</c:otherwise>
	</c:choose>
	</div>
</body>
</html>
